﻿Imports System.Net.Sockets
Imports System.Text

Public Class Form1
    Public clientSocket As New System.Net.Sockets.TcpClient()
    Public serverStream As NetworkStream
    Public readData As String
    Public infiniteCounter As Integer

    Private Sub PlayButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayButton.Click
        Dim i As Integer = 1
        Dim conn = False
        MessageBox.Show("Παρακαλώ περιμένετε να βρεθεί αντίπαλος." & Environment.NewLine & " Η φόρμα θα κλείσει προσωρινά !", "client error")
        For i = 1 To 2
            Try
                Me.Hide()
                clientSocket.Connect("192.168.1.64", 8888)
                serverStream = clientSocket.GetStream()
                Form2.Show()

                conn = True

            Catch ex As Exception

            End Try
        Next

        If conn = False Then
            MessageBox.Show("Δεν υπάρχει διαθέσιμος αντίπαλος. Προσπαθήστε Ξανά !", "client error")
            Me.Show()
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Credits.Show()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        howtoplay.Show()
    End Sub
End Class